$().ready(function() {
    $('#content').tinymce({
        script_url: '../public/tinyMCE/tiny_mce.js',
        theme: "advanced",
        language: "zh",
        plugins: "safari,pagebreak,layer,table,advhr,advimage,inlinepopups,insertdatetime,media,contextmenu,paste,directionality,noneditable,visualchars,nonbreaking,googlemap",
        theme_advanced_buttons1: "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,fontselect,fontsizeselect,|,forecolor,backcolor,|,sub,sup,|,ltr,rtl",
        theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,media,cleanup,|,insertdate,inserttime,|,hr,removeformat,visualaid,|,charmap,advhr",
        theme_advanced_buttons3: "tablecontrols,|,visualchars,nonbreaking,|,code,preview,codehighlighting,googlemap,fullscreen",
        theme_advanced_toolbar_location: "top",
        theme_advanced_toolbar_align: "left",
        theme_advanced_statusbar_location: "bottom",
        theme_advanced_resizing: true,
        width: "100%",
        height: "400",
        content_css: "js/mycontent.css",
        convert_urls: false,
        relative_urls: false,
        extended_valid_elements: "script[type|src],iframe[src|style|width|height|scrolling|marginwidth|marginheight|frameborder],",
        init_instance_callback: 'someFunction',
        file_browser_callback: 'myCustomFileBrowser'
    })
});
function someFunction(inst) {
    var h = $(window).height();
    var w = $(window).width();
    var winid = inst.editorId;
    w = w == 0 ? '100%': w;
    h = h == 0 ? 600: h;
    $('#' + winid + '_ifr').css({
        width: w,
        height: h - 220
    })
}
function myCustomFileBrowser(field_name, url, type, win) {
    var winid = win.frameElement.id;
    var cmsURL = 'index.php?archive=filemanage&action=filemanage&listfunction=filelist&iframeid=' + winid + '&fileinputid=' + field_name + '&iframename=' + self.frameElement.getAttribute('name');
    if (cmsURL.indexOf("?") < 0) {
        cmsURL = cmsURL + "?checkfrom=edit&filetype=" + type
    } else {
        cmsURL = cmsURL + "&checkfrom=edit&filetype=" + type
    }
    parent.windowsdig('文件浏览', 'iframe:' + cmsURL, '900px', '480px', 'iframe')
}